﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace WpfDemo.Common
{
    /// <summary>
    /// Window窗体扩展属性，MVVM打开窗体
    /// </summary>
    public static class WindowExtend
    {
        #region Windows 窗体

        public static void Register(this Window win, string key)
        {
            WindowManager.Regiter(key, win.GetType());
        }

        public static void Register(this Window win, string key, Type t)
        {
            WindowManager.Regiter(key, t);
        }

        public static void Register<T>(this Window win, string key)
        {
            WindowManager.Regiter<T>(key);
        }
        #endregion

        #region UserControl 用户控件

        public static void RegisterUc(this UserControl win, string key)
        {
            WindowManager.Regiter(key, win.GetType());
        }

        public static void RegisterUc(this UserControl win, string key, Type t)
        {
            WindowManager.Regiter(key, t);
        }
        /// <summary>
        /// 在用户控件中注册窗体
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="win">用户空间扩展方法</param>
        /// <param name="key">窗体名称</param>
        public static void RegisterUc<T>(this UserControl win, string key)
        {
            WindowManager.Regiter<T>(key);
        }
        #endregion

    }
}
